import 'package:flutter/material.dart';
import 'package:template/common/assets.dart';
import 'package:template/pages/login.dart';

import '../common/button.dart';

class Welcome extends StatelessWidget {
  const Welcome({Key? key}) : super(key: key);

  Widget _buildButtons(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 20),
      child: Row(
        children: [
          //skip
          TextButton(
            onPressed: () {},
            child: const Text("Skip",
                style: TextStyle(
                    fontSize: 15,
                    color: Color(0xff2B2A2A),
                    fontWeight: FontWeight.w300)),
          ),

          //弹开
          const Spacer(),

          //get start
          ButtonWidget(
            text: "Get start",
            width: 139,
            height: 42,
            onPress: () => {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => const LoginPage()),
              )
            },
          ),
        ],
      ),
    );
  }

  Padding _buildText() {
    return const Padding(
      padding: EdgeInsets.symmetric(horizontal: 38),
      child: Text(
        "welcome",
        style: TextStyle(
            fontSize: 20,
            fontWeight: FontWeight.bold,
            color: Color(0xff2B2B2A),
            height: 23 / 20),
      ),
    );
  }

  Widget _buildView(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        //标题
        _buildText(),

        const SizedBox(
          height: 20,
        ),
        //图片

        Image.asset(
          AssetsImages.welcomePng,
          height: 300,
          width: double.infinity,
          fit: BoxFit.none,
        ),

        const SizedBox(
          height: 20,
        ),
        //按钮组
        _buildButtons(context)
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: _buildView(context),
      ),
    );
  }
}
